package com.ftg.learn.annotationforme.provider;

import org.apache.ibatis.annotations.Param;

/**
 * 查询向导
 * @author 布衣
 */
public class ShopProductProvider {

    public String listByProName(@Param("proName") String proName){
        String sql = "select p.id,\n" +
                "       pro_name,\n" +
                "       pro_price,\n" +
                "       pro_desc,\n" +
                "       pro_status,\n" +
                "       case\n" +
                "           when pro_type = 0 then '瓶装'\n" +
                "           when pro_type = 1 then '桶装'\n" +
                "           when pro_type = 2 then '箱'\n" +
                "           else '其它'\n" +
                "           end pro_type,\n" +
                "       pro_num\n" +
                "from shop_product p\n" +
                "    join shop_category sc\n" +
                "       on p.pro_category_id = sc.id";
        sql += " where 1 = 1";
        if(proName != null){
            sql += " and pro_name like concat('%',#{proName},'%')";
        }
        return sql;
    }

}
